﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Master/Site.master" AutoEventWireup="false" ValidateRequest="false"
    MaintainScrollPositionOnPostback="true" CodeFile="MyTargetList.aspx.vb" Inherits="private_secure_members_manage_MyLists" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 737px;
        }
        .auto-style1 {
            height: 25px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <h2>
        Manage Your List(s)</h2>
    <h3>
        List(s) hold electronic Contact Details of your prospects/clients/customers/members</h3>
    <hr />
    <p />
    <table id="table1" class="style1">
<%--        <tr>
            <td class="style2">
                A List is a named group of people you will communicate with (via email or Text)<br />
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>--%>
        <tr>
            <td valign="top" class="style2">
                Your Organisation(s):&nbsp;<br />
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="MyEntityODS"
                    DataTextField="Name" DataValueField="ID" Width="209px" 
                    AppendDataBoundItems="true" >
                    <asp:ListItem Value="0">Please Choose ...</asp:ListItem>
                </asp:DropDownList>
                &nbsp;
                <asp:Button ID="Button2" runat="server" Text="New List" CausesValidation="false" />
        <asp:Button ID="Button10" runat="server" Text="Cancel" />
                <asp:ObjectDataSource ID="MyEntityODS" runat="server" OldValuesParameterFormatString="original_{0}"
                    SelectMethod="GetData" TypeName="LogginsLogDSTableAdapters.usp_GetPersonEntityListByPersonIdTableAdapter">
                    <SelectParameters>
                        <asp:Parameter DbType="Guid" Name="UserId" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td valign="top" class="style2">
                Below are your List(s) for the selected organisation/entity/club/group.
            </td>
            <td rowspan="2" valign="top">
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="style2" valign="top">
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" DataKeyNames="ID" 
                    DataSourceID="SqlDataSource1" Width="100%"
                    CellPadding="4" ForeColor="#333333" Height="20px">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <table style="width: 100%;">
                                    <tr>
                                        <td class="auto-style1">
                                            <asp:LinkButton ID="LinkButton222" runat="server" CausesValidation="False" CommandArgument='<%# Eval("ID") %>' CommandName="Edit" Text="Edit"></asp:LinkButton>
                                        </td>
                                        <td class="auto-style1">
                                            <asp:LinkButton ID="LinkButton444" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton>
                                            <asp:ConfirmButtonExtender ID="LinkButton444_ConfirmButtonExtender" runat="server" ConfirmText="Delete selected list ?" Enabled="True" TargetControlID="LinkButton444">
                                            </asp:ConfirmButtonExtender>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:LinkButton ID="LinkButton111" runat="server" CausesValidation="False" CommandName="Update"
                                    Text="Update"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton222" runat="server" CausesValidation="False"
                                    CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="RowNum" HeaderText=" # " ReadOnly="True" SortExpression="RowNum">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" InsertVisible="False"
                            ReadOnly="True" Visible="False" />
                        <asp:BoundField DataField="EntityId" HeaderText="EntityId" SortExpression="EntityId"
                            Visible="False" />
                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                        <asp:TemplateField HeaderText="Type" SortExpression="TypeName" Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("TypeName") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddllkpListType" runat="server" DataSourceID="lkpListTypeODS"
                                    DataTextField="Name" DataValueField="Id" SelectedValue='<%# Bind("ListTypeId") %>'>
                                </asp:DropDownList>
                                <asp:ObjectDataSource ID="lkpListTypeODS" runat="server" DeleteMethod="Delete" InsertMethod="Insert"
                                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="LogginsLogDSTableAdapters.usp_lkp_ListTypeTableAdapter"
                                    UpdateMethod="Update">
                                    <DeleteParameters>
                                        <asp:Parameter Name="Id" Type="Byte" />
                                    </DeleteParameters>
                                    <InsertParameters>
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Active" Type="Boolean" />
                                    </InsertParameters>
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Byte" />
                                    </SelectParameters>
                                    <UpdateParameters>
                                        <asp:Parameter Name="Id" Type="Byte" />
                                        <asp:Parameter Name="Name" Type="String" />
                                        <asp:Parameter Name="Active" Type="Boolean" />
                                    </UpdateParameters>
                                </asp:ObjectDataSource>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="ListTypeId" SortExpression="ListTypeId" Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("ListTypeId") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ListTypeId") %>'></asp:TextBox>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Note" HeaderText="Note" SortExpression="Note" />
                        <asp:CheckBoxField DataField="SingleUse" HeaderText="SingleUse" SortExpression="SingleUse"
                            Visible="False" />
                        <asp:BoundField DataField="DateCreated" HeaderText="Created" SortExpression="DateCreated" />
                        <asp:BoundField DataField="RecipientsCount" HeaderText="#Recipients" ReadOnly="True"
                            SortExpression="RecipientsCount">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Columns">
                            <ItemTemplate>
                                
                                    <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="false" CommandName="Select" Text="Manage"></asp:LinkButton>
                                
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Recipients">
                            <ItemTemplate>
                               
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandArgument='<%# Eval("ID") %>' CommandName="PopulateList" Text="Manage"></asp:LinkButton>
                                
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Filters">
                            <EditItemTemplate>
                                <asp:HyperLink ID="hlkFilters" runat="server" NavigateUrl="~/private/secure_members/manage/MyTargetListFilter.aspx">Manage</asp:HyperLink>
                            </EditItemTemplate>
                            <ItemTemplate>
                                    <asp:HyperLink ID="hlkFilters" runat="server" NavigateUrl="~/private/secure_members/manage/MyTargetListFilter.aspx">Manage</asp:HyperLink>
                               
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <EmptyDataTemplate>
                        Please select an Organisation/Entity from above or get started by clicking
                        add New List to create a new list.<br />
                        <br />
                        <asp:LinkButton ID="LinkButton11" runat="server" CausesValidation="False" CommandName="NewList"
                            Text="New List"></asp:LinkButton>
                    </EmptyDataTemplate>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    DeleteCommand="usp_TargetListDelete" DeleteCommandType="StoredProcedure" InsertCommand="usp_TargetListInsert"
                    InsertCommandType="StoredProcedure" SelectCommand="usp_TargetListSelectByEntityId_RecipientCount"
                    SelectCommandType="StoredProcedure" UpdateCommand="usp_TargetListUpdate" UpdateCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="ID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="EntityId" Type="Int32" />
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="MsgRef" Type="String" />
                        <asp:Parameter Name="BillingRef" Type="String" />
                        <asp:Parameter Name="ListTypeId" Type="Byte" />
                        <asp:Parameter Name="Note" Type="String" />
                        <asp:Parameter Name="SingleUse" Type="Boolean" />
                        <asp:Parameter Name="DateCreated" Type="DateTime" />
                        <asp:Parameter Name="IsDefault" Type="Boolean" />
                        <asp:Parameter Name="DateDiscarded" Type="Boolean" />
                        <asp:Parameter Name="Active" Type="Boolean" />
                        <asp:Parameter Direction="InputOutput" Name="TargetListId" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownList1" Name="EntityID" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="ID" Type="Int32" />
                        <asp:Parameter Name="EntityId" Type="Int32" />
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="MsgRef" Type="String" />
                        <asp:Parameter Name="BillingRef" Type="String" />
                        <asp:Parameter Name="ListTypeId" Type="Byte" />
                        <asp:Parameter Name="Note" Type="String" />
                        <asp:Parameter Name="SingleUse" Type="Boolean" />
                        <asp:Parameter Name="DateCreated" Type="DateTime" />
                        <asp:Parameter Name="IsDefault" Type="Boolean" />
                        <asp:Parameter Name="DateDiscarded" Type="Boolean" />
                        <asp:Parameter Name="Active" Type="Boolean" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="style2">
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="style2">
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td class="style2" valign="top">
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
    </table>
    <%--        <asp:Panel ID="Panel1" runat="server" Style="display: none" CssClass="modalPopup">
    --%>
    <asp:Panel ID="pnlRegistrationSuccess" runat="server"  CssClass="modalPopup">
        <%--                <input id="btnCancel" type="button" value="X" Style="display: none" style="float: right; background-color: #FF0000;" />
        --%>
        <asp:Button ID="btnCancel" runat="server" CausesValidation="false" Text="X" Style="float: right;
            background-color: #FF0000;" />
        <h2>
            <asp:Label ID="lblAction" runat="server" Text="Details of Your List"></asp:Label></h2>
        <table style="width: 100%;">
            <tr>
                <td valign="top">
                    Name of List:
                </td>
                <td valign="top">
                    <asp:TextBox ID="txtName" runat="server" Width="160px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Enter the Name of the list."
                        ControlToValidate="txtName"></asp:RequiredFieldValidator>
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td valign="top">
                    Your Note:
                </td>
                <td valign="top">
                    <asp:TextBox ID="txtNote" runat="server" Height="113px" TextMode="MultiLine" Width="396px"></asp:TextBox>
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <asp:Button ID="btnInsert" runat="server" Text="Insert" />
                    <asp:Button ID="btnUpdate" runat="server" Text="Update" />
                    <asp:Label ID="lblInfo" runat="server" Text=""></asp:Label>
                    <asp:HiddenField ID="hdfSelectedId" runat="server" />
                    <asp:ObjectDataSource ID="InsertTargetListODS" runat="server" DeleteMethod="Delete"
                        InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
                        TypeName="LogginsLogDSTableAdapters.usp_TargetListTableAdapter" UpdateMethod="Update">
                        <DeleteParameters>
                            <asp:Parameter Name="ID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="EntityId" Type="Int32" />
                            <asp:Parameter Name="Name" Type="String" />
                            <asp:Parameter Name="MsgRef" Type="String" />
                            <asp:Parameter Name="BillingRef" Type="String" />
                            <asp:Parameter Name="ListTypeId" Type="Byte" />
                            <asp:Parameter Name="Note" Type="String" />
                            <asp:Parameter Name="SingleUse" Type="Boolean" />
                            <asp:Parameter Name="DateCreated" Type="DateTime" />
                            <asp:Parameter Name="IsDefault" Type="Boolean" />
                            <asp:Parameter Name="DateDiscarded" Type="Boolean" />
                            <asp:Parameter Name="Active" Type="Boolean" />
                            <asp:ControlParameter ControlID="lblInfo" Direction="ReturnValue" Name="TargetListId" PropertyName="Text" Type="Object" />
                        </InsertParameters>
                        <SelectParameters>
                            <asp:Parameter Name="EntityID" Type="Int32" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="ID" Type="Int32" />
                            <asp:Parameter Name="EntityId" Type="Int32" />
                            <asp:Parameter Name="Name" Type="String" />
                            <asp:Parameter Name="MsgRef" Type="String" />
                            <asp:Parameter Name="BillingRef" Type="String" />
                            <asp:Parameter Name="ListTypeId" Type="Byte" />
                            <asp:Parameter Name="Note" Type="String" />
                            <asp:Parameter Name="SingleUse" Type="Boolean" />
                            <asp:Parameter Name="DateCreated" Type="DateTime" />
                            <asp:Parameter Name="IsDefault" Type="Boolean" />
                            <asp:Parameter Name="DateDiscarded" Type="Boolean" />
                            <asp:Parameter Name="Active" Type="Boolean" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="LogginsLogDSTableAdapters.usp_TargetListTableAdapter" UpdateMethod="Update">
                        <DeleteParameters>
                            <asp:Parameter Name="ID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="EntityId" Type="Int32" />
                            <asp:Parameter Name="Name" Type="String" />
                            <asp:Parameter Name="MsgRef" Type="String" />
                            <asp:Parameter Name="BillingRef" Type="String" />
                            <asp:Parameter Name="ListTypeId" Type="Byte" />
                            <asp:Parameter Name="Note" Type="String" />
                            <asp:Parameter Name="SingleUse" Type="Boolean" />
                            <asp:Parameter Name="DateCreated" Type="DateTime" />
                            <asp:Parameter Name="IsDefault" Type="Boolean" />
                            <asp:Parameter Name="DateDiscarded" Type="Boolean" />
                            <asp:Parameter Name="Active" Type="Boolean" />
                            <asp:Parameter Direction="InputOutput" Name="TargetListId" Type="Object" />
                        </InsertParameters>
                        <SelectParameters>
                            <asp:Parameter Name="EntityID" Type="Int32" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="ID" Type="Int32" />
                            <asp:Parameter Name="EntityId" Type="Int32" />
                            <asp:Parameter Name="Name" Type="String" />
                            <asp:Parameter Name="MsgRef" Type="String" />
                            <asp:Parameter Name="BillingRef" Type="String" />
                            <asp:Parameter Name="ListTypeId" Type="Byte" />
                            <asp:Parameter Name="Note" Type="String" />
                            <asp:Parameter Name="SingleUse" Type="Boolean" />
                            <asp:Parameter Name="DateCreated" Type="DateTime" />
                            <asp:Parameter Name="IsDefault" Type="Boolean" />
                            <asp:Parameter Name="DateDiscarded" Type="Boolean" />
                            <asp:Parameter Name="Active" Type="Boolean" />
                        </UpdateParameters>
                    </asp:ObjectDataSource>
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
        </table>
        <asp:Button ID="btnRegistrationSuccess" runat="server" Text="Button" Style="display: none;" />
        <asp:ModalPopupExtender ID="InsertPopupExtender" runat="server" PopupControlID="pnlRegistrationSuccess"
            DynamicServicePath="" Enabled="True" TargetControlID="btnRegistrationSuccess"
            BackgroundCssClass="modalBackground" DropShadow="true">
        </asp:ModalPopupExtender>
    </asp:Panel>
    <asp:Panel ID="Panel1" runat="server"  CssClass="modalPopup">
        <%--                <input id="btnCancel" type="button" value="X" Style="display: none" style="float: right; background-color: #FF0000;" />
        --%>
        <asp:Button ID="Button1" runat="server" CausesValidation="false" Text="X" Style="float: right;
            background-color: #FF0000;" />
        <h2>
            <asp:Label ID="Label4" runat="server" Text="Recipient Data For this List"></asp:Label></h2>
        <table style="width: 100%;">
            <tr>
                <td valign="top">
                    <asp:SqlDataSource ID="Sqllkp_TgtLstClmnLst_DDL" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                        SelectCommand="usp_GetTargetListColumnList_incl_excl" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="Label8" Name="TargetListId" PropertyName="Text"
                                Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:Label ID="Label3" runat="server" Text=""></asp:Label>
                    <asp:Panel ID="pnlSelectedColumns" runat="server">
                        <strong>Columns for your List</strong>
                        <asp:GridView ID="grdSelectedFields" runat="server" AutoGenerateColumns="False" DataKeyNames="ColumnName"
                            DataSourceID="Sqllkp_TgtLstClmnLst_DDL" EmptyDataText="Nothing">
                            <Columns>
                                <asp:TemplateField HeaderText="Column Name" SortExpression="ColumnName" Visible="False">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ColumnName") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label5" runat="server" Text='<%# Bind("ColumnName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Selected" SortExpression="Selected">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Selected") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkboxFilled" runat="server" Checked='<%# Bind("Selected") %>'
                                            Text='<%# Eval("ColumnName") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        <asp:Button ID="btnInsertCol" runat="server" CausesValidation="false" Text="Save" />
                        <asp:Label ID="Label8" runat="server" Visible="False"></asp:Label>
                        </asp:Panel>
                </td>
            </tr>
        </table>
        <asp:Button ID="Button5" runat="server" Text="Button" Style="display: none;" />
        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1"
            DynamicServicePath="" Enabled="True" TargetControlID="Button5" BackgroundCssClass="modalBackground"
            DropShadow="true">
        </asp:ModalPopupExtender>
    </asp:Panel>
    <asp:Panel ID="Panel2" runat="server"  CssClass="modalPopup">
        <%--                <input id="btnCancel" type="button" value="X" Style="display: none" style="float: right; background-color: #FF0000;" />
        --%>
        <asp:Button ID="Button3" runat="server" CausesValidation="false" Text="X" Style="float: right;
            background-color: #FF0000;" />
        <h2>
            <asp:Label ID="Label6" runat="server" Text="PopUp Heading3"></asp:Label></h2>
        <table style="width: 100%;">
            <tr>
                <td valign="top">
                    <asp:Label ID="Label7" runat="server" Text=""></asp:Label>
                </td>
            </tr>
        </table>
        <asp:Button ID="Button6" runat="server" Text="Button" Style="display: none;" />
        <asp:ModalPopupExtender ID="ModalPopupExtender2" runat="server" PopupControlID="Panel2"
            DynamicServicePath="" Enabled="True" TargetControlID="Button6" BackgroundCssClass="modalBackground"
            DropShadow="true">
        </asp:ModalPopupExtender>
    </asp:Panel>
</asp:Content>
